import { Service } from "cl-admin";
import BaseService from "@/service/base";
import { isArray, last } from "cl-admin/utils";
@Service("wechatrobotUserTask")
class WechatrobotUserTask extends BaseService {

    //获取群发任务列表
    userTaskList({ appoint_date,size, appoint_dept_id,  ...args }){
        let params = {
            btime:'',
            etime:'',
            id_add_dept:"",
            size,
			...args
		};
        if (appoint_date && appoint_date.length ) {
			params.btime = appoint_date[0];
			params.etime = appoint_date[1];
		}
        if (appoint_dept_id && isArray(appoint_dept_id)) {
			params.id_add_dept = last(appoint_dept_id);
		}
        return this.$get("/userTaskList", { params }).then(res => {
            console.log(res)
            return {
              list: res.data,
              pagination: {
                ...params,
                size,
                total: res.total
              }
            };
        })
    }
    //获取员工客户列表
    getUserCustomer(params){
        return this.$post("/getUserCustomer", params);
    }
    //新建群发任务
    createUserTask(params){
        return this.$post("/createUserTask", params);
    }
    //获取员工列表
    getUserList(params){
        return this.$get("/getUserList", { params });
    }
    //获取员工列表
    getUserTagList(params){
        return this.$get("/getUserTagList", { params });
    }
}
export default WechatrobotUserTask;
